1413. 逐步求和得到正数的最小值
为保证权益,题目请参考 1413. 逐步求和得到正数的最小值(From LeetCode).
解决方案1
Python
python
# 1413. 逐步求和得到正数的最小值
# https://leetcode.cn/problems/minimum-value-to-get-positive-step-by-step-sum/
from typing import List
import itertools
class Solution:
def minStartValue(self, nums: List[int]) -> int:
return max(1 - min(itertools.accumulate(nums)), 0)
if __name__ == "__main__":
so = Solution()
print(so.minStartValue([-3, 2, -3, 4, 2]))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15